from llama_index.core import SimpleDirectoryReader, VectorStoreIndex, Settings, StorageContext, load_index_from_storage

from config.embeddings import embed_model_local_bge_small
from config.llm import deepseek_llm
from tool.file_tool import getRootPath

# 设置LLM和Embedding模型
Settings.llm = deepseek_llm()
Settings.embed_model = embed_model_local_bge_small()

#获取根目录
rootPath = getRootPath()

# 重建存储上下文
storage_context = StorageContext.from_defaults(persist_dir=rootPath + '/store/vector_index')

# 加载索引
load_index = load_index_from_storage(storage_context)

query_engine = load_index.as_query_engine()
response = query_engine.query("员工的年假有几天？")
print(response)